package com.iron.gateway.config;

import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import reactor.core.publisher.Mono;

/**
 * 路由限流配置类
 *
 * @author YT
 * @date 2019-07-10
 */
@Deprecated
//@Configuration
public class RateLimiterConfiguration {

    /**
     * ip 限流策略
     *
     * @return
     */
    @Bean(value = "remoteKeyResolver")
    public KeyResolver remoteKeyResolver() {
        return exchange -> Mono.just(exchange.getRequest().getRemoteAddress().getHostName());
    }
}
